package com.training1.util;

public class SequenceNumberUtil {
	
	//复投
	public static final String FT_PREFIX ="FT0";
	
	//抢点
	public static final String QD_PREFIX ="QD0";
	
	//退款
	public static final String TK_PREFIX ="TK0";
		
	//点位账户
	public static final String ZH_PREFIX ="ZH0";
	
	//卡券
	public static final String FS_PREFIX = "FS0";
	
	//会员账户充值
	public static final String CZ_PREFIX = "CZ0";
	
	//会员账户充值
	public static final String WX_PREFIX = "WX9990";
	
	public final static String ORDER_PREFIX = "DD0";

	//发货单编号
	public final static String DELIVER_NUMBER = "FH0";
	
	//抢点
	public static final String ORDER_NUMBER ="TX0";

	/**
	 * 生成节点编号
	 * 
	 * @param branchCode - 开单中心编号代码
	 * @return String
	 */
	public static String generateNodeNumber(String branchCode) {
		long naroTime = getCurrentTime();
		if(branchCode == null || branchCode.length() != 5) {
			return null;
		}
		return branchCode + String.valueOf(naroTime);
	}
	/**
	 * 返回订单编号
	 * 
	 * @return String
	 */
	public static String generateOrderNumber() {
		long naroTime = getCurrentTime();
		return ORDER_PREFIX + naroTime;
	}

	/**
	 * 返回发货单编号
	 * 
	 * @return String
	 */
	public static String generateDeliverNumber() {
		long naroTime = getCurrentTime();
		return DELIVER_NUMBER + naroTime;
	}

	/**
	 * 抢点
	 * @return
	 */
	public static String generateQiangDianNumber() {
		long naroTime = getCurrentTime();
		return QD_PREFIX + naroTime;
	}
	
	/**
	 * 复投
	 * @return
	 */
	public static String generateFuTouNumber() {
		long naroTime = getCurrentTime();
		return FT_PREFIX + naroTime;
	}
	
	/**
	 * 点位账户表
	 * @return
	 */
	public static String generateZHNumber() {
		long naroTime = getCurrentTime();
		return ZH_PREFIX + naroTime;
	}
	
	/**
	 * 复投
	 * @return
	 */
	public static String generateRefundNumber() {
		long naroTime = getCurrentTime();
		return TK_PREFIX + naroTime;
	}
	
	/**
	 * 网销
	 * @return
	 */
	public static String generateWXNumber() {
		long naroTime = getCurrentTime();
		return WX_PREFIX + naroTime;
	}
	
	/**
	 * 开单中心
	 * @return
	 */
	public static String generateBarchNumber(String barch) {
		long naroTime = getCurrentTime();
		return barch + naroTime;
	}
	
	/**
	 * 会员账户充值
	 * @return
	 */
	public static String memberRechargeNumber(){
		long naroTime = getCurrentTime();
		return CZ_PREFIX + naroTime;
	}
	
	/**
	 * 卡券
	 * @return
	 */
	public static String cardgenerateNumber(){
		long naroTime = getCurrentTime();
		return FS_PREFIX + naroTime;
	}
	
	private static long getCurrentTime(){
		try {
			Thread.sleep(1);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return System.currentTimeMillis();
	}
	
	
	public static void main(String[] args) {
		String a = null;
		for(int i=0;i<100000;i++){
			String b = cardgenerateNumber();
			if(b.equals(a)){
				System.out.println(b);
			}
			a = b;
		}
		
	}
	
	/**
	 * 抢点
	 * @return
	 */
	public static String generateOrderNumber1() {
		long naroTime = getCurrentTime();
		return ORDER_NUMBER + naroTime;
	}
}
